from typing import Optional, Dict, Any
from datetime import datetime
from pydantic import BaseModel


class DatawarehouseConfigBase(BaseModel):
    name: str
    type: str
    host: str
    port: int
    username: Optional[str] = None
    password: Optional[str] = None
    database_name: Optional[str] = None
    connection_params: Optional[Dict[str, Any]] = None
    is_default: bool = False
    is_active: bool = True
    description: Optional[str] = None


class DatawarehouseConfigCreate(DatawarehouseConfigBase):
    pass


class DatawarehouseConfigUpdate(BaseModel):
    name: Optional[str] = None
    type: Optional[str] = None
    host: Optional[str] = None
    port: Optional[int] = None
    username: Optional[str] = None
    password: Optional[str] = None
    database_name: Optional[str] = None
    connection_params: Optional[Dict[str, Any]] = None
    is_default: Optional[bool] = None
    is_active: Optional[bool] = None
    description: Optional[str] = None


class DatawarehouseConfig(DatawarehouseConfigBase):
    id: int
    created_at: datetime
    updated_at: datetime
    created_by: str

    class Config:
        from_attributes = True


class DatawarehouseConfigPublic(BaseModel):
    """公开的配置信息，不包含密码"""
    id: int
    name: str
    type: str
    host: str
    port: int
    username: Optional[str] = None
    database_name: Optional[str] = None
    connection_params: Optional[Dict[str, Any]] = None
    is_default: bool
    is_active: bool
    description: Optional[str] = None
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True 